<?php

namespace app\modules\setting\models\fsjl;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use app\modules\setting\models\fsjl\EtcSendCreatorDetail;
use yii\helpers\Json;

/**
 * EtcSendCreatorDetailSearch 是 `app\modules\setting\models\fsjl\EtcSendCreatorDetail` 的搜索模型.
 */
class EtcSendCreatorDetailSearch extends EtcSendCreatorDetail
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'status'], 'integer'],
            [['email', 'list_uid'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // 绕过scenario()在父类中的实现
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @param integer $pageSize
     *
     * @return ActiveDataProvider
     */
    public function search($params,$select=null)
    {
        $query = EtcSendCreatorDetail::find()->select($select ? $select : "*");

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => ['pageSize' => ArrayHelper::getValue($params,"pageSize",10),'defaultPageSize' => 10,'pageSizeParam' => 'pageSize'],
            'sort' => ['defaultOrder' => ['id' => SORT_DESC]],
        ]);

        $this->load($params,"");

        if (!$this->validate()) {
            // 如果您不想在验证失败时返回任何记录，请取消下面一行的注释
            // $query->where('0=1');
            return $dataProvider;
        }

        // 过滤条件
        $query->andFilterWhere([
            'id' => $this->id,
        ]);


                $query->andFilterWhere(['like', 'email', $this->email])                                ->andFilterWhere(['like', 'list_uid', $this->list_uid])
                                ->andFilterWhere(['like', 'status', $this->status]);
            
        return $dataProvider;
    }
}
